/*
* TreeNode.h
*
*  Created on: Mar 28, 2011
*      Author: hxu
*      Tree node can only be HEAD, LST, LEAF
*/

#ifndef TREENODE_H_
#define TREENODE_H_

//#include "NetNode.h"
#include "Segment.h"

#define HEAD 'r'	// for general list
#define BUF 'b'
#define CON 'm'
#define VIA 't'
#define LST 'l'	// for general list
#define LEAF 's'	// for general list

namespace Cxuh {

	template<class TT> class Tree;

	template <class Type>
	class TreeNode {
		template <class TT> friend class Tree;	// Tree is defined somewhere else
	public:
		TreeNode(char t);	// t is the type of node
		TreeNode(TreeNode<Type>*);	// copy a treenode
		virtual ~TreeNode();
		//bool operator== (TreeNode<Type>& b);
		int getID();	// return id
		char getType();
		Point<Type> getPt(); // return value.pt
		virtual Cxuh::TreeNode<Type>* getHlink(); // return value.pt
	private:
		TreeNode<Type>* parent;
		Segment<Type>* pseg;	// seg between parent and this
		TreeNode<Type>* tlink;	// next node belonging to the same general list
		union{
			Cxuh::Point<Type> *pt;	// HEAD and LEAF, position
			Cxuh::TreeNode<Type>* hlink;	// LST, pointer to the head of the sub tree
		} value;
	protected:
		int id;
		char ntype;
	};

}

#endif /* TREENODE_H_ */
